package com.zhanglijie.base.fiberAndThreadCompare;

/**
 * @author zhanglijie
 * @version 1.0
 * @since 1.1.0 2022/3/13 0013 0:59
 */
public class MyThreadTest {
    public static void main(String[] args) throws InterruptedException {
        long cur = System.currentTimeMillis();
         int num = 100000; //18402
       // int num = 100; //62
       Thread[] threads = new Thread[num];
       for(int i=0;i<num;i++){
           threads[i] = new Thread(()->{
               calcute();
           });
       }
       for(int i=0;i<num;i++){
           threads[i].start();
           threads[i].join();
       }

        System.out.println("总计耗时"+(System.currentTimeMillis()-cur));
    }

    private static void calcute() {
        int result = 0;
        for(int i=0;i<1000;i++){
            for(int j=0;j<2000;j++){
                result++;
            }
        }
        System.out.println("该线程任务执行完毕！！！");
    }
}
